//package com.dsunsoft.rtu.core.config;
//
//import com.dsunsoft.rtu.common.constant.CommonConstants;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.AmqpAdmin;
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.core.RabbitAdmin;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.config.ConfigurableBeanFactory;
//import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Scope;
//
///**
// * RabbitMq配置
// */
//@Slf4j
//@Configuration
//public class RabbitMqConfig {
//
//    @Autowired
//    private RabbitProperties properties;
//
//    /**
//     * 定义队列
//     */
//    @Bean
//    public Queue directQueue() {
//        return new Queue(CommonConstants.TASK_QUEUE, true);
//    }
//
//    /**
//     * amqpAdmin
//     */
//    @Bean
//    public AmqpAdmin amqpAdmin(ConnectionFactory connectionFactory) {
//        log.debug("RabbitProperties: addresses[{}:{}]", properties.getHost(), properties.getPort());
//        return new RabbitAdmin(connectionFactory);
//    }
//
//    /**
//     * rabbitTemplate
//     */
//    @Bean
//    public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
//        RabbitTemplate template = new RabbitTemplate(connectionFactory);
//        template.setReplyTimeout(60000L); // 设置返回超时时间(毫秒),60000=1分钟
//        return template;
//    }
//
//    /**
//     * 因为要设置回调类，所以应是prototype类型，如果是singleton类型，则回调类为最后一次设置
//     */
//    @Bean
//    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
//    public RabbitTemplate rabbitTemplateNew(ConnectionFactory connectionFactory) {
//        return new RabbitTemplate(connectionFactory);
//    }
//}
